%%
%% This is file `se2-design.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% se2-design.dtx  (with options: `class')
%% 
%% Copyright (C) 2007        Vance Lankhaar
%% Copyright (C) 2002, 2003  Simon Law
%% 
%%   This program is free software; you can redistribute it and/or modify
%%   it under the terms of the GNU General Public License as published by
%%   the Free Software Foundation; either version 2 of the License, or
%%   (at your option) any later version.
%% 
%%   This program is distributed in the hope that it will be useful,
%%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%%   GNU General Public License for more details.
%% 
%%   You should have received a copy of the GNU General Public License
%%   along with this program; if not, write to the Free Software
%%   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307  USA
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{se2-design}[2003/05/20 v2.6 U. of Waterloo work reports]
\newif\ifseTwo@draft \seTwo@draftfalse
\DeclareOption{draft}{%
  \seTwo@drafttrue
  \write10{([draft] Draft report; including instruction text)}}
\newif\ifseTwo@final \seTwo@finalfalse
\DeclareOption{final}{%
  \seTwo@finaltrue
  \write10{([final] Final Revision; student numbers included)}}
\newif\ifuwwkrpt@math \uwwkrpt@mathfalse
\DeclareOption{math}{%
  \uwwkrpt@mathtrue
  \write10{([math] Mathematics report)}}
\newif\ifuwwkrpt@ece \uwwkrpt@ecefalse
\DeclareOption{ece}{%
  \uwwkrpt@ecetrue
  \write10{([ece] Electrical and Computer Engineering report)}}
\newif\ifuwwkrpt@se \uwwkrpt@sefalse
\DeclareOption{se}{%
  \uwwkrpt@setrue
  \write10{([se] Software Engineering report)}}
\DeclareOption{10pt}{\ClassWarning{se2-design}{%
  You requested a 10pt font but this report must be 11pt}}
\DeclareOption{12pt}{\ClassWarning{se2-design}{%
  You requested a 12pt font but reports must be 11pt}}
\newcommand{\@blockletter}{}
\DeclareOption{modifiedletter}{%
  \newcommand{\@blockletter}{}}
\DeclareOption{blockletter}{%
  \newcommand{\@blockletter}{\setlength{\parindent}{0pt}}}
\DeclareOption*{\PassOptionsToClass {\CurrentOption}{article}}
\ProcessOptions
\LoadClass[titlepage,11pt]{article}
\RequirePackage{ifthen}
\RequirePackage{fullpage}
\ifx\FP@margin\undefined
  \newlength{\FP@margin}
\fi
\newlength{\vance@margin}
\setlength{\vance@margin}{1in}
\setlength{\FP@margin}{1in}
\setlength{\textwidth}{\paperwidth}
\addtolength{\textwidth}{-1\FP@margin}
\addtolength{\textwidth}{-1\FP@margin}
\setlength{\oddsidemargin}{\FP@margin}
\addtolength{\oddsidemargin}{-1in}
\setlength{\evensidemargin}{\FP@margin}
\addtolength{\evensidemargin}{-1in}
\RequirePackage{setspace}
\newcommand{\uwwkrpt@spacing}{\singlespacing}
\newlength{\uwwkrpt@parskip}
\setlength{\uwwkrpt@parskip}{1ex}
\setlength{\parskip}{\uwwkrpt@parskip}
\RequirePackage{url}
\urlstyle{sf}
\renewcommand{\title}[1]{%
  \renewcommand{\@title}{#1}%
  \renewcommand{\@@title}{#1}}
\newcommand{\@@title}{\ClassError{se2-design}%
  {No \noexpand\title given}{}}
\renewcommand{\author}[1]{%
  \renewcommand{\@author}{#1}%
  \renewcommand{\@@author}{#1}}
\newcommand{\@@author}{\ClassError{se2-design}%
  {No \noexpand\author given}{}}
\renewcommand{\date}[1]{%
  \renewcommand{\@date}{#1}%
  \renewcommand{\@@date}{#1}}
\newcommand{\@@date}{\today}

\newcommand{\school}[1]{\renewcommand{\@school}{#1}}
  \newcommand{\@school}{\ClassError{se2-design}%
    {No \noexpand\school given}{}}
\newcommand{\faculty}[1]{\renewcommand{\@faculty}{#1}}
  \newcommand{\@faculty}{\ClassError{se2-design}%
    {No \noexpand\faculty given}{}}
\newcommand{\term}[1]{\renewcommand{\@term}{\textsc{\lowercase{#1}}}}
  \newcommand{\@term}{\ClassError{se2-design}%
    {No \noexpand\term given}{}}
\newcommand{\program}[1]{\renewcommand{\@program}{#1}}
  \newcommand{\@program}{\ClassError{se2-design}%
    {No \noexpand\program given}{}}
\newcommand{\thetitle}{\@@title}
\newcommand{\theauthor}{\@@author}
\newcommand{\thegroup}{\seTwo@group}
\newcommand{\theschool}{\@school}
\newcommand{\thefaculty}{\@faculty}
\newcommand{\theterm}{\@term}
\newcommand{\theprogram}{\@program}
\newcommand{\thedate}{\@@date}
\RequirePackage{textcase}
\renewcommand{\maketitle}{%
  \begin{titlepage}
  \begin{singlespacing}
  \let\footnotesize\small
  \let\footnoterule\relax
  \let \footnote \thanks
  \begin{center}
    {\Large \MakeTextUppercase{\theschool} \par \thefaculty \par}%
    {\large \theprogram}%
  \end{center}
  \null\vfill%
  \begin{center}%
    {\huge \@title \par}%
  \end{center}\par
  \null\vfill%
  \begin{center}%
    {\large
      \textbf{Prepared by} \par
      \ifthenelse{\boolean{seTwo@final}}{%
\begin{tabular}[t]{ccr@{@}l}%
  \multicolumn{4}{c}{Group \thegroup}
      }{
\begin{tabular}[t]{cr@{@}l}%
 \multicolumn{3}{c}{Group \thegroup}
      }
\seTwo@members%
      \end{tabular}\par}%
  \null\vfill%
    {\large \@date \par}%       % Set date in \large size.
  \end{center}
  \null\vfill%
  \@thanks
  \end{singlespacing}
  \end{titlepage}%
  \setcounter{footnote}{0}%
  \global\let\thanks\@gobble
  \global\let\maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}
\newenvironment{letter}{%
  \everyvbox={\thispagestyle{empty}}%
  \@setletterpagenum%
  \ifthenelse{\boolean{uwwkrpt@math}}
    {\raggedright}{}
  \@blockletter%
  \singlespacing%
  \noindent\@@author\\\@address\par\noindent%
  \@@date \par\noindent%
  \@chair, Program Director\\*\@chairaddress\par\noindent%
  Dear \@chair:%
  \begin{center}\textbf{Re: Submission of my work term report.}\end{center}}
  {\par I hereby confirm that I have received no further help other
  than what is mentioned above in writing this report.
  \ifthenelse{\boolean{uwwkrpt@ece}
              \or \boolean{uwwkrpt@math}
              \or \boolean{uwwkrpt@se}}
    {I also confirm that this report has not been previously submitted
    for academic credit at this or any other academic institution.}
    {This report was written entirely by me and has not received
    any previous academic credit at this or any other institution.}
  \ifthenelse{\boolean{uwwkrpt@math}}{%
    \par The Faculty of Mathematics requests that you evaluate this report
    for command of topic and technical content/analysis.  Following your
    assessment, the report, together with your evaluation, will be submitted
    to the Math Undergrad Office for evaluation on campus by qualified
    work report markers.  The combined marks will determine whether the
    report will receive credit and whether it will be considered for an
    award.
    \par I would like to thank you for your assistance in preparing this
    document.}{}%
  \par\noindent
  \begin{minipage}{\textwidth}
  \setlength{\parskip}{\uwwkrpt@parskip}
  \vspace*{\uwwkrpt@parskip}
  Yours sincerely,\\*%
  \rule{0in}{0.3in}\\*{\hrule \@width 3in}%
  \noindent\@@author, \@uwid
  \par\noindent
  Encl.%
  \end{minipage}
  \@setpostletterpagenum\uwwkrpt@spacing%
  \global\let\@@author\@empty
  \global\let\@@title\@empty
  \global\let\@@date\@empty
  \global\let\uwid\relax
  \global\let\@uwid\@empty
  \global\let\email\relax
  \global\let\@email\@empty
  \global\let\employer\relax
  \global\let\@employer\@empty
  \global\let\employeraddress\relax
  \global\let\@employeraddress\@empty
  \global\let\address\relax
  \global\let\@address\@empty
  \global\let\chair\relax
  \global\let\@chair\@empty
  \global\let\chairaddress\relax
  \global\let\@chairaddress\@empty
  \global\let\school\relax
  \global\let\@school\@empty
  \global\let\faculty\relax
  \global\let\@faculty\@empty
  \global\let\term\relax
  \global\let\@term\@empty
  \global\let\program\relax
  \global\let\@program\@empty
  \global\let\confidential\relax
  \global\let\@confidential\@empty
}
\newcommand{\frontmatter}{%
  \clearpage
  \@notmainsect%
  \pagenumbering{roman}%
  \uwwkrpt@spacing%
}
\newcommand{\mainmatter}{%
  \clearpage
  \@mainsect%
  \pagenumbering{arabic}%
  \ifthenelse{\boolean{uwwkrpt@math}}{\let\section\section@rig}
  \global\def\dotzero{}
  \global\def\@secdotzerostart##1{}
  \global\def\@secdotzeroend##1{}
  \ifthenelse{\boolean{uwwkrpt@math}}{%
    \renewcommand{\@secdotzerostart}[1]{%
      \let\quad@rig\quad
      \ifthenelse{\equal{##1}{section}}{%
        \renewcommand{\quad}{.0\quad@rig}%
        \renewcommand{\dotzero}{.0}}{\renewcommand{\dotzero}{}}
    }
    \renewcommand{\@secdotzeroend}[1]
      {\ifthenelse{\equal{##1}{section}}{\let\quad\quad@rig}}
  }{}%
  \global\def\@appendixtitle{}
}
\let\appendix@rig\appendix
\renewcommand{\appendix}{%
  \@mainsect%
  \ifthenelse{\boolean{uwwkrpt@math}}{%
    \renewcommand{\@secdotzerostart}[1]{\renewcommand{\dotzero}{}}
    \renewcommand{\@secdotzeroend}[1]{}
    }{}%
  \ifthenelse{\boolean{uwwkrpt@ece}}
    {\renewcommand{\@appendixtitle}{Appendix }}{}
  \appendix@rig%
}
\newcommand{\backmatter}{%
  \clearpage
  \@notmainsect%
  \ifthenelse{\boolean{uwwkrpt@math}}%
    {\renewcommand{\section}{\clearpage\section@rig}}{}%
}
\newenvironment{summary}
  {\@notmainsect}
  {\@mainsect}
\newcommand{\@notmainsect}{%
  \def\@sect##1##2##3##4##5##6[##7]##8{%
    \@tempskipa ##5\relax
    \ifdim \@tempskipa>\z@
      \begingroup
        ##6{%
          \@hangfrom{\hskip ##3}%
            \interlinepenalty \@M ##8\@@par}%
      \endgroup
      \csname ##1mark\endcsname{##7}%
      \addcontentsline{toc}{##1}{##7}%
    \else
      \def\@svsechd{%
        ##6{\hskip ##3\relax
        \@svsec ##8}%
        \csname ##1mark\endcsname{##7}%
        \addcontentsline{toc}{##1}{##7}}%
    \fi
    \@xsect{##5}}%
}

\newcommand{\@mainsect}{%
  \def\@sect##1##2##3##4##5##6[##7]##8{%
    \ifnum ##2>\c@secnumdepth
      \let\@svsec\@empty
    \else
      \refstepcounter{##1}%
      \@secdotzerostart{##1}
      \protected@edef\@svsec{\@appendixtitle\@seccntformat{##1}\relax}%
      \@secdotzeroend{##1}
    \fi
    \@tempskipa ##5\relax
    \ifdim \@tempskipa>\z@
      \begingroup
        ##6{%
          \@hangfrom{\hskip ##3\relax\@svsec}%
            \interlinepenalty \@M ##8\@@par}%
      \endgroup
      \csname ##1mark\endcsname{##7}%
      \addcontentsline{toc}{##1}{%
        \ifnum ##2>\c@secnumdepth \else
          \protect\numberline{\@appendixtitle\csname the##1\endcsname\dotzero}
          \protect\phantom{\@appendixtitle}%
        \fi
        ##7}%
    \else
      \def\@svsechd{%
        ##6{\hskip ##3\relax
        \@svsec ##8}%
        \csname ##1mark\endcsname{##7}%
        \addcontentsline{toc}{##1}{%
          \ifnum ##2>\c@secnumdepth \else
            \protect\numberline{\@appendixtitle\csname the##1\endcsname\dotzero}
            \protect\phantom{\@appendixtitle}%
          \fi
          ##7}}%
    \fi
    \@xsect{##5}}%
}
\let\section@rig\section
\renewcommand{\section}{\clearpage\section@rig}
\newcommand{\@setletterpagenum}{}
\newcommand{\@setpostletterpagenum}{\setcounter{page}{0}}
\ifthenelse{\boolean{uwwkrpt@ece} \or \boolean{uwwkrpt@se}}{%
  \renewcommand{\@setletterpagenum}{\setcounter{page}{2}}
  \renewcommand{\@setpostletterpagenum}{}
}{}
\renewcommand{\contentsname}{Table of Contents}
\let\tableofcontents@rig\tableofcontents
\renewcommand{\tableofcontents}{%
  \clearpage
  \begin{singlespacing}
  \setlength{\parskip}{0pt}
  \tableofcontents@rig\par
  \end{singlespacing}
}
\renewcommand*\l@section[2]{%
    \ifnum \c@tocdepth >\m@ne
      \addpenalty{-\@highpenalty}%
      \vskip 1.0em \@plus\p@
      \setlength\@tempdima{1.5em}%
      \begingroup
        \parindent \z@ \rightskip \@pnumwidth
        \parfillskip -\@pnumwidth
        \leavevmode \bfseries
        \advance\leftskip\@tempdima
        \hskip -\leftskip
        #1\nobreak\
          \leaders\hbox{$\m@th
          \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
          mu$}\hfil\nobreak\hb@xt@\@pnumwidth{\hss #2}\par
        \penalty\@highpenalty
      \endgroup
    \fi%
  }
\let\listoffigures@rig\listoffigures
\renewcommand{\listoffigures}{%
  \clearpage
  \begin{singlespacing}
  \listoffigures@rig \addcontentsline{toc}{section}{List of Figures}%
  \end{singlespacing}
}

\let\listoftables@rig\listoftables
\renewcommand{\listoftables}{%
  \clearpage
  \begin{singlespacing}
  \listoftables@rig \addcontentsline{toc}{section}{List of Tables}%
  \end{singlespacing}
}
\let\table@rig\table
\let\endtable@rig\endtable
\let\figure@rig\figure
\let\endfigure@rig\endfigure
  \renewenvironment{figure}[1][htbp]{\begin{figure@rig}[#1]}{\end{figure@rig}}
  \renewenvironment{table}[1][htbp]{\begin{table@rig}[#1]}{\end{table@rig}}

\let\thefigure@rig\thefigure
\renewcommand{\thefigure}{\thesection.\thefigure@rig}

\let\thetable@rig\thetable
\renewcommand{\thetable}{\thesection.\thetable@rig}

\newcommand\addtodef[3][\def]{%
\expandafter#1\expandafter#2\expandafter{#2#3}%
}%
\newcommand{\srsref}[1]{{\textsc{srs\sectionSymbol#1}}}
\ifthenelse{\boolean{seTwo@draft}}{%
  \newenvironment{instructions}{}{}
}{
  \newenvironment{instructions}{\begin{comment}}{\end{comment}}
  % don't know yet how to mark ``ignore this text''
}
\newcommand{\seTwo@group}{}
\newcommand{\group}[1]{\renewcommand{\seTwo@group}{#1}}
\newcommand{\seTwo@members}{}
\newcommand{\member}[4]{\relax}
\ifthenelse{\boolean{seTwo@final}}{%
  \renewcommand{\member}[4]{\addtodef{\seTwo@members}{\\ #1 & #2 & #3 & #4}}
}{
  \renewcommand{\member}[4]{\addtodef{\seTwo@members}{\\ #1 & #3 & #4}}
}
\bibliographystyle{ieeetr}
\let\bib@rig\bibliography
\renewcommand{\bibliography}[1]{%
  \clearpage
  \begin{singlespacing}
  \bibliography@intoc \bib@rig{#1}\par
  \end{singlespacing}
}
\newcommand{\refn@me}{References}
\newcommand{\bibliography@intoc}{%
  \renewcommand{\refname}{%
    \addtocounter{section}{1}%
    \arabic{section}\hspace{2.5ex}\refn@me%
    \addcontentsline{toc}{section}{%
      \numberline{\arabic{section}}{\refn@me}}}%
}
\ifthenelse{\boolean{uwwkrpt@ece}
            \or \boolean{uwwkrpt@math}
            \or \boolean{uwwkrpt@se}}{%
  \renewcommand{\bibliography@intoc}{%
      \addcontentsline{toc}{section}{\refn@me}}%
}{}
\endinput
%%
%% End of file `se2-design.cls'.
